<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/10
 * Time: 14:33
 */

namespace Timer\Models;
use Timer\Lib\OPT_CONST;

class Dispatcher
{
    /*
            根据操作码分发操作
        */
    public static function dispatcherOpt($req_ary)
    {

        if(isset($req_ary['operation']))
        {
            switch($req_ary['operation'])
            {
                case 'BuildTimer':
                    $timerModel = new TimerModel();
                    $result = $timerModel->buildTimer($req_ary);
                    break;
                case 'DeleteTimer':
                    $timerModel = new TimerModel();
                    $result = $timerModel->deleteTimer($req_ary);
                    break;
                default:
                    $result = OPT_CONST::MISSING_OPERATION;	//数据格式不正确，缺少操作码
                    break;
            }
            return $result;
        }
        else
        {
            return OPT_CONST::MISSING_OPERATION;	//缺少操作码
        }
    }
}